function getExplorerInfo() {
    var explorer = window.navigator.userAgent.toLowerCase();
    //ie 
    if (explorer.indexOf("msie") >= 0) {
        var ver = explorer.match(/msie ([\d.]+)/)[1];
        return { type: "IE", version: ver };
    }
        //firefox 
    else if (explorer.indexOf("firefox") >= 0) {
        var ver = explorer.match(/firefox\/([\d.]+)/)[1];
        return { type: "Firefox", version: ver };
    }
        //Chrome
    else if (explorer.indexOf("chrome") >= 0) {
        var ver = explorer.match(/chrome\/([\d.]+)/)[1];
        return { type: "Chrome", version: ver };
    }
        //Opera
    else if (explorer.indexOf("opera") >= 0) {
        var ver = explorer.match(/opera.([\d.]+)/)[1];
        return { type: "Opera", version: ver };
    }
        //Safari
    else if (explorer.indexOf("Safari") >= 0) {
        var ver = explorer.match(/version\/([\d.]+)/)[1];
        return { type: "Safari", version: ver };
    }
}

//临时，手机端其它页都跳到首页
function tempJump(){
	var ww = window.innerWidth;
	var url = window.location.href;
	var list = url.split("/");
	var page = list[list.length - 1];
	var list2 = page.split('.');
	var name = list2[0];
	if(ww <= 768 && (name == 'ecjia' || name == 'about') ){
		location.href="index.html"
	}
}
tempJump();

$(function(){
	$(window).resize(function(){
		tempJump();
	})

	// 手机端不可缩放，pc端可缩放
	function PC_MOB_RESIZE(){
		var ww = $(window).width();
		var roo = $("html");
		var MV = $("meta[name='viewport']")
		var MV_PC = "width=device-width, user-scalable=yes";
		var MV_MOBILE = "width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0";
		if(ww <= 768){
			if(!roo.hasClass("html-mobile")){
				roo.addClass("html-mobile").removeClass("html-pc");
				MV.attr("content", MV_MOBILE);
			}
		}else{
			if(!roo.hasClass("html-pc")){
				roo.addClass("html-pc").removeClass("html-mobile");
				MV.attr("content", MV_PC);
			}
		}
	}
	$(window).resize(function(){
		PC_MOB_RESIZE();
	})
	PC_MOB_RESIZE();

	$("[data-iframe]").click("click",function(){
		var $this = $(this);
		var video = $this.attr("data-iframe");
		layer.open({
		  type: 2,
		  title: false,
		  closeBtn: 1, //不显示关闭按钮
		  shade: 0.3,
		  skin: 'layer-alert-video',
		  area: ['900px', '563px'],
		  anim: 0,
		  content: [video, 'no'] //iframe的url，no代表不显示滚动条
		});
	});
	

	/* --------------------- index --------------------- */
	if($(".page-index").length > 0){
		$(window).scroll(function(){
			wt();
		});
		wt();
		function wt(){
			var wt = $(document).scrollTop();
			var hd = $(".page-index .header");
			if(wt > 0){
				hd.addClass("header_down");
			}else{
				hd.removeClass("header_down");
			}
		}
	}

	$(".page-index .index-slide").slide({
		mainCell: '.bd ul',
		titCell: '.hd ul',
		autoPage: true,
		effect: 'fold',
		autoPlay: true,
		interTime: 3000,
	})

	$(".page-index .section-2 .section-tab .tab-item").mouseenter(function(){
		$(this).addClass("on").siblings().removeClass("on");
	})
	$(".page-index .section-2 .tab-1-slide").slide({
		mainCell: '.bd ul',
		titCell: '.hd ul li'
	})
	$(".page-index .section-2-1 .s-slide").slide({
		mainCell: '.bd .bd-list',
		titCell: '.hd ul li',
		effect: 'fold',
		autoPlay: true
	})

	$(".page-index .section-5").slide({
		mainCell: '.bd .bd-wrap',
		titCell: '.hd .list li',
		effect: 'fold'
	})
	$(".page-index .section-5 .inner-slide-1").slide({
		mainCell: '.bd2 ul',
		titCell: '.hd2 li',
		effect: 'fold'
	})
	$(".page-index .section-5 .inner-slide-2").slide({
		mainCell: '.bd2 ul',
		titCell: '.hd2 li',
		effect: 'fold'
	})
	$(".page-index .section-5 .inner-slide-3").slide({
		mainCell: '.bd2 ul',
		titCell: '.hd2 li',
		effect: 'fold'
	})
	$(".page-index .section-5 .inner-slide-4").slide({
		mainCell: '.bd2 ul',
		titCell: '.hd2 li',
		effect: 'fold'
	})
	$(".page-index .section-5 .inner-slide-5").slide({
		mainCell: '.bd2 ul',
		titCell: '.hd2 li',
		effect: 'fold'
	})

	$(".page-index .section-6").slide({
		mainCell: '.bd ul',
		titCell: '.hd li',
		effect: 'fold'
	})

	// 底部数字滚动
	var wp = $(".page-index .section-9");
	if (wp.length > 0) {
		$(window).scroll(function(){
			var wst = $(window).scrollTop();
			var oft = wp.offset().top;
			if(wst + $(window).height() > oft && !wp.hasClass("active")){
				var num = $(".num");
	    		num.find("span").removeClass("active");
			}
		});
	}

	/* --------------------- weshop --------------------- */


	$(".page-weshop .section-6 .section-slide").slide({
		mainCell: '.bd ul',
		titCell: '.hd li',
		effect: 'fold'
	})

	$(".page-weshop .section-3").slide({
		mainCell: '.bd ul',
		titCell: '.hd li',
		effect: 'fold',
		delayTime: 500,
		endFun: function(i,c,s,t,m,tar,p,n) {
			var wrap = ".page-weshop";
			SwiperAndScroll(wrap, i, m);
		}
	})
	function SwiperAndScroll(wrap,i,m){
		var client = getExplorerInfo();
		if(client.type == "IE" && ["9.0","8.0","7.0","6.0"].indexOf(client.version) > -1){
			return;
		}


		var li = m.find("li").eq(i)
		var j = i + 1;
		var $img = $(wrap + ".mod-mobile-scroll.img-" + j);
		if(!$img.hasClass("j-slided")){
			$img.addClass("j-slided");
			new Swiper(wrap + ".mod-mobile-scroll.img-" + j, {
		        scrollbar: wrap + ".mod-mobile-scroll.img-" + j + ' .swiper-scrollbar',
		        direction: 'vertical',
		        slidesPerView: 'auto',
		        mousewheelControl: true,
		        freeMode: true,
				roundLengths : true, //防止文字模糊
		        grabCursor: true,
		    });
		}
	}

	/* --------------------- applet --------------------- */
	$(".page-applet .section-4 .s-slide").slide({
		mainCell: '.bd ul',
		titCell: '.hd li',
		effect: 'fold',
		autoPlay: 3000
	})

	/* --------------------- appshopkeeper --------------------- */

	$(".page-apps .section-4").slide({
		mainCell: '.bd ul',
		titCell: '.hd li',
		effect: 'fold',
		delayTime: 500,
		endFun: function(i,c,s,t,m,tar,p,n) {
			var wrap = ".page-apps";
			SwiperAndScroll(wrap, i, m);
		}
	})

	/* --------------------- app --------------------- */

	$(".page-app .section-4").slide({
		mainCell: '.bd ul',
		titCell: '.hd li',
		effect: 'fold',
		delayTime: 500,
		endFun: function(i,c,s,t,m,tar,p,n) {
			var wrap = ".page-app";
			SwiperAndScroll(wrap, i, m);
		}
	})

	/* --------------------- platform --------------------- */
	$(".page-platform .section-3").slide({
		mainCell: '.bd ul',
		titCell: '.hd li',
		effect: 'fold'
	})
	// 平台4楼动画
	function s4Animation(){
		var delay = 500;
		var stepCls = ['on1','on2','on3','on4','on5'];
		var wrap = $(".page-platform .s-animation");
		var wrap1 = wrap.find(".i-small");
		var i1 = wrap.find(".item-1");
		var i2 = wrap.find(".item-2");
		var i3 = wrap.find(".item-3");
		var i4 = wrap.find(".item-4");
		var ok1 = i1.find(".i-ok");
		var ok2 = i2.find(".i-ok");
		var ok3 = i3.find(".i-ok");
		var ok4 = i4.find(".i-ok");
		var b1 = i1.find(".i-gray");
		var wrap2 = i1.find(".i-big");
		var bin = wrap2.find(".inner");
		var btop = wrap2.find(".b-top")
		var bn1 = wrap2.find(".n1");
		var bn2 = wrap2.find(".n2");
		var bn3 = wrap2.find(".n3");
		var bb = wrap2.find(".b-banner");
		var bh3 = wrap2.find(".b-h3");
		var bl1i1 = wrap2.find(".b-list-1 .dd-1");
		var bl1i2 = wrap2.find(".b-list-1 .dd-2");
		var bl1i3 = wrap2.find(".b-list-1 .dd-3");
		var bl1i4 = wrap2.find(".b-list-1 .dd-4");
		var bl2i1 = wrap2.find(".b-list-2 .dd-1");
		var bl2i2 = wrap2.find(".b-list-2 .dd-2");
		var bl2i3 = wrap2.find(".b-list-2 .dd-3");
		var bl2i4 = wrap2.find(".b-list-2 .dd-4");
		var bar = wrap2.find(".bar");
		var barspan = bar.find("span");
		var timeLong = 500;
		var timeShort = 300;
		var timeShorter = 150;
		var timeTransition = 800;
		// 列表出现
		setTimeout(function(){i1.addClass(stepCls[0]); }, delay);
		delay+=timeShort;
		setTimeout(function(){i2.addClass(stepCls[0]); }, delay);
		delay+=timeShort;
		setTimeout(function(){i3.addClass(stepCls[0]); }, delay);
		delay+=timeShort;
		setTimeout(function(){i4.addClass(stepCls[0]); }, delay);
		delay+=timeShort;
		// 按钮选中
		setTimeout(function(){ok1.addClass(stepCls[0]); }, delay);
		delay+=timeShorter;
		setTimeout(function(){ok2.addClass(stepCls[0]); }, delay);
		delay+=timeShorter;
		setTimeout(function(){ok3.addClass(stepCls[0]); }, delay);
		delay+=timeShorter;
		setTimeout(function(){ok4.addClass(stepCls[0]); }, delay);
		delay+=timeTransition;
		// 后面三个方框隐藏
		setTimeout(function(){
			i2.addClass(stepCls[1]); 
			i3.addClass(stepCls[1]); 
			i4.addClass(stepCls[1]); 
			wrap2.show();
		}, delay);
		delay+=timeShort;
		// 第一个方框放大
		setTimeout(function(){i1.addClass(stepCls[1]); }, delay);
		delay+=timeTransition;
		// 灰色banner上移
		setTimeout(function(){wrap1.addClass(stepCls[0]); }, delay);
		delay+=timeTransition;
		// 彩色banner显示,其它隐藏
		setTimeout(function(){
			bb.addClass(stepCls[0]); 
			b1.addClass(stepCls[0]); 
			btop.addClass(stepCls[0]);
		}, delay);
		setTimeout(function(){bn1.addClass(stepCls[0]); }, delay);
		delay+=timeShort;
		setTimeout(function(){bn2.addClass(stepCls[0]); }, delay);
		delay+=timeShort;
		setTimeout(function(){bn3.addClass(stepCls[0]); }, delay);
		// h3显示，列表1出现
		setTimeout(function(){
			bh3.addClass(stepCls[0]); 
			bl1i1.addClass(stepCls[0]); 
			bl1i2.addClass(stepCls[0]); 
			bl1i3.addClass(stepCls[0]); 
			bl1i4.addClass(stepCls[0]); 
			bar.addClass(stepCls[0]);
		}, delay);
		delay+=timeTransition;
		// 列表1分散
		setTimeout(function(){
			bl1i1.addClass(stepCls[1]); 
			bl1i2.addClass(stepCls[1]); 
			bl1i3.addClass(stepCls[1]); 
			bl1i4.addClass(stepCls[1]); 
		}, delay);
		delay+=timeTransition;
		// 列表二出现
		setTimeout(function(){
			bl2i1.addClass(stepCls[0]); 
			bl2i2.addClass(stepCls[0]); 
			bl2i3.addClass(stepCls[0]); 
			bl2i4.addClass(stepCls[0]); 
			bar.addClass(stepCls[0]);
		}, delay);
		setTimeout(function(){
			bl2i1.addClass(stepCls[1]); 
			bl2i2.addClass(stepCls[1]); 
			bl2i3.addClass(stepCls[1]); 
			bl2i4.addClass(stepCls[1]); 
		}, delay);
		delay+=timeTransition;
		// 页面向下滚动
		setTimeout(function(){
			bin.addClass(stepCls[0]); 
			barspan.addClass(stepCls[0]); 
		}, delay);
		delay+=timeTransition;
		delay+=timeTransition;
		// 页面消失
		setTimeout(function(){
			i1.addClass(stepCls[2]); 
		}, delay);
		delay+=timeTransition;
		// 重置class
		setTimeout(function(){
			stepCls.map(function(v,i){
				wrap.find("*").removeClass(v);
			});
			wrap2.hide();
			s4Animation();
		}, delay);
	}
	s4Animation();


	/* --------------------- platformsupply --------------------- */

	$(".page-platformsupply .section-4").slide({
		mainCell: '.bd ul',
		titCell: '.hd li',
		effect: 'fold'
	})


	/* --------------------- admission --------------------- */

	$(".page-admission .section-6 .s-slide").slide({
		mainCell: '.bd ul',
		titCell: '.hd li',
		effect: 'fold'
	})

	

	$(".page-unmannedretail .section-6 .slide").slide({
		mainCell : '.bd ul',
		titCell : '.hd li',
		effect : 'fade',
		delayTime: 0
	})

	$(".page-international .gjb-video-content").slide({
		mainCell : ".gv-info",
		titCell: '.gv-slide li',
		trigger : "click",
		effect : "fade",
		delayTime: 0
	});

	$(".gjb-slide").slide({
		mainCell : ".bd ul",
		trigger : "click",
		effect : "fade",
		delayTime: 0
	});

	$(".index-price .price-slide").slide({
		mainCell : ".bd",
		trigger : "mouseover",
		effect : "fade"
	});

	/* --------------------- live --------------------- */
	$(".page-live .section-3 .s-slide").slide({
		mainCell: '.bd ul',
		titCell: '.hd li',
		effect: 'fold'
	})
	$(".page-live .section-slide").slide({
		mainCell: '.bd',
		titCell: '.jump-list li',
		effect: 'fold',
		trigger: "click"
	})
	// mobile
	new Swiper(".page-live .mob-s2 .swiper-container");
	


	/* --------------------- 后台 --------------------- */

	$(".body-backstage  .section-slide .s-slide").slide({
		mainCell: '.bd ul',
		titCell: '.hd li',
		effect: 'fold'
	})


	/* --------------------- im --------------------- */

	$(".page-im  .section-3 .s-slide").slide({
		mainCell: '.bd ul',
		titCell: '.hd li',
		effect: 'fold'
	})


	/* --------------------- u8+ --------------------- */

	$(".page-erpu8  .section-4 .s-slide").slide({
		mainCell: '.bd ul',
		titCell: '.hd li',
		effect: 'fold'
	})

	/* --------------------- function --------------------- */
	$(".page-function .service_tabs li").mouseenter(function(){
		var index = $(this).index();
		$(this).addClass("current").siblings().removeClass("current");
		$(".service_con").find(".table").eq(index).show().siblings().hide();
	});

	/* --------------------- authorization --------------------- */
	// 手机端同步
	function sameAuthorUpdate(){
		var content1 = $(".page-authorization .page_pc .section-4 .mod-like-table").clone();
		var content2 = $(".page-authorization .page_pc .section-5 .mod-like-table").clone();
		var content3 = $(".page-authorization .page_pc .section-4-1 .mod-like-table").clone();
		var mobBody1 = $(".page-authorization .mob-s2-1 .s-content");
		var mobBody2 = $(".page-authorization .mob-s2-2 .s-content");
		var mobBody3 = $(".page-authorization .mob-s2-3 .s-content");
		// content1.find(".th p").each(function(){
		// 	var txt = simplePrice($(this).text());
		// 	console.log($(this))
		// 	$(this).text(txt)
		// })

		// content2.find(".th p").each(function(){
		// 	var txt = simplePrice($(this).text());
		// 	$(this).text(txt)
		// })
		// content3.find(".th p").each(function(){
		// 	var txt = simplePrice($(this).text());
		// 	$(this).text(txt)
		// })
		mobBody1.append(content1);
		mobBody2.append(content2);
		mobBody3.append(content3);


		function simplePrice(str){
			// ￥19,000 转换成 19000
			return str.replace(/[￥\,]/g,'');
		}
	}
	sameAuthorUpdate();

	/* --------------------- faq --------------------- */
    $(".page-faq .course_main").slide({"titCell":".tabs li","mainCell":".items",titOnClassName:"current"});

    /* --------------------- update --------------------- */
    $(".page-update .page_pc .update-warp").slide({titCell:".update-tabs li",mainCell:".update-content",titOnClassName:"curr"});
    $(".page-update .page_pc *[ectype='year']").on("click",function(){
		var val = $(this).data("value");
		
		$(".year-item-"+val+"").slideToggle(500);
		
		if($(this).hasClass("down")){
			$(this).removeClass("down");
		}else{
			$(this).addClass("down");
		}
	});
	// 手机端效果同步
	function sameUpdate(){
		var content = $(".page-update .page_pc .update-warp").clone();
		var mobBody = $(".page-update .mob-body");
		var pcTimes = $(".page-update .page_pc .update_quency");
		var mobTimes = $('.j-update-times-m');

		// 内容同步
		mobBody.append(content);
		mobTimes.text(pcTimes.find("span").text());

		// js特效同步
	    $(".page-update .page_mobile .update-warp").slide({titCell:".update-tabs li",mainCell:".update-content",titOnClassName:"curr"});
	    $(".page-update .page_mobile *[ectype='year']").on("click",function(){
			var val = $(this).data("value");
			
			$(".year-item-"+val+"").slideToggle(500);
			
			if($(this).hasClass("down")){
				$(this).removeClass("down");
			}else{
				$(this).addClass("down");
			}
		});
	}
	sameUpdate();

	/* --------------------- manual --------------------- */	
	$(".page-manual .manual-warp").slide({titCell:".manual-tabs li",mainCell:".manual-content",titOnClassName:"curr"});
    
    /* --------------------- saas --------------------- */	
	$(".page-saas [ectype='card-area'] li").hover(function(){
		$(this).addClass("active").siblings().removeClass("active");
	});

	/* --------------------- about --------------------- */	
	// 关于我们页面切换
	function getHash(){
		arg=location.href.split("#");
		return arg[1];
	}
	function setAboutTabLine(index){
		if($(".body-about").length == 0) return;
		var step = 196; //一个item的宽度
		var left = step*index;
		$(".body-about .subnav .tips1").show().css({"left": left+"px"});
	}
	function setAboutTab(){
		if($(".body-about").length == 0) return;
		var hash = getHash();
		var arr = ['index','contact','team','office','honor'];
		if(!hash){hash="index"}
		var index = arr.indexOf(hash);
		var boxs = $(".body-about .about-details .detail-item")
		boxs.eq(index).show().siblings(":visible").hide();
		setAboutTabLine(index);
	}
	setAboutTab();
	$(".body-about .subnav li a").click(function(){
		setTimeout(function(){
			setAboutTab();
		}, 200)
	})
})